package com.ylx.excel.utils;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;

import java.util.List;

public class EasyExcelUtil {

    public static ExcelWriter getDefaultExcelWriter(String path, List<List<String>> headers) {
        return EasyExcel.write(path).head(headers)
                .registerWriteHandler(ExcelUtils.STYLE)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                .build();
    }

    public static WriteSheet getWriteSheet(Integer pageNum) {
        return EasyExcel.writerSheet(pageNum - 1, "第" + pageNum + "页").build();
    }

}
